

<template>
  <div class="container">
    <el-button type="primary" class="button" @click="checkStatus">签到</el-button>
<!--    <el-button type="primary" class="button" @click="drawer = true">提交审批</el-button>-->
    <el-drawer
      style="margin: 15px"
      title="我是标题"
      :visible.sync="drawer"
      :with-header="false">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="活动名称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
          <el-select v-model="form.region" placeholder="请选择活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="活动时间">
          <el-col :span="11">
            <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
          </el-col>
          <el-col class="line" :span="2">-</el-col>
          <el-col :span="11">
            <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
          </el-col>
        </el-form-item>
        <el-form-item label="即时配送">
          <el-switch v-model="form.delivery"></el-switch>
        </el-form-item>
        <el-form-item label="活动性质">
          <el-checkbox-group v-model="form.type">
            <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
            <el-checkbox label="地推活动" name="type"></el-checkbox>
            <el-checkbox label="线下主题活动" name="type"></el-checkbox>
            <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="特殊资源">
          <el-radio-group v-model="form.resource">
            <el-radio label="线上品牌商赞助"></el-radio>
            <el-radio label="线下场地免费"></el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="活动形式">
          <el-input type="textarea" v-model="form.desc"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
      <div class="demo-drawer__footer">
        <el-button @click="cancelForm">取 消</el-button>
        <el-button type="primary" @click="$refs.drawer.closeDrawer()" :loading="loading">{{ loading ? '提交中 ...' : '确 定' }}</el-button>
      </div>
    </el-drawer>
  </div>

</template>

<script>
import { updateAttendanceStatus } from "@/api/attendance";
import { mapGetters } from 'vuex'
export default {
  data(){
    return{
      updateDate:{},
      drawer: false,
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  computed: {
    ...mapGetters([ "userInfo","employInfo"])// 使用 mapGetters 获取 getUserInfo 函数
  },
  created() {
    console.log(this.employInfo)
  },
  methods:{
    onSubmit() {
      console.log('submit!');
    },
    checkStatus(){
      this.updateDate.userId = this.employInfo.id

      const today = new Date();
      const year = today.getFullYear();
      let month = (today.getMonth() + 1).toString().padStart(2, '0'); // 获取月份，并确保两位数格式
      let day = today.getDate().toString().padStart(2, '0'); // 获取日期，并确保两位数格式

      const formattedDate = `${year}${month}${day}`;
      console.log(formattedDate)
      this.updateDate.day = formattedDate

      this.updateDate.adtStatu = 1
      updateAttendanceStatus(this.updateDate)
      this.$message({
        message: '签到成功！请勿重复签到',
        type: 'success'
      });

    }
  }
}
</script>

<style scoped lang="scss">
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #f0f0f0; /* 设置背景颜色 */
}

.button {
  margin: 0 10px;
  padding: 12px 24px; /* 稍微调整按钮内边距 */
  font-size: 16px;
  border-radius: 30px; /* 使用更大的圆角 */
  background: linear-gradient(135deg, #409eff, #66b1ff); /* 添加渐变背景 */
  color: white; /* 按钮文字颜色 */
  border: none; /* 移除按钮边框 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); /* 更加立体感的阴影 */
  transition: transform 0.2s, box-shadow 0.2s; /* 添加按钮点击效果 */

  &:hover {
    transform: translateY(-2px); /* 按钮向上移动一点 */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3); /* 悬停时更深的阴影 */
  }

  &:active {
    transform: translateY(0); /* 恢复按钮点击前的位置 */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* 点击时较浅的阴影 */
  }
}
</style>
